// 100pts
#include <cstdio>
constexpr int MaxN = 1e6 + 5;
int n;
int p[MaxN];
int w[MaxN];
char s[MaxN];
char t[MaxN];
int main()
{
    freopen("hard.in", "r", stdin);
    freopen("hard.out", "w", stdout);
    int answer = 0;
    bool solved = false;
    scanf("%d", &n);
    scanf("%s", s + 1);
    scanf("%s", t + 1);
    for (int i = 1; i <= n; i++)
    {
        p[i] = s[i] == '1' ? 1 : 0;
    }
    for (int i = 1; i <= n; i++)
    {
        w[i] = t[i] == '1' ? 1 : 0;
    }
    int change_block = 0;
    int las = 0;
    int late = -0x3f3f3f3f;
    auto calc = [](int x) { return x == 0 ? 0 : x == 1 ? 1 : 1 + x / 2; };
    for (int i = 1; i <= n; i++)
    {
        int xt = i;
        for (; xt + 1 <= n && w[xt + 1] == w[i];)
        {
            xt++;
        }
        int ch = 0;
        for (int j = i; j <= xt - 1; j++)
        {
            if ((p[j] ^ w[j]) != (p[j + 1] ^ w[j + 1]))
            {
                ch++;
            }
        }
        if (ch == 0)
        {
            late++;
            if ((p[i] ^ w[i]) == 0 && (p[xt] ^ w[xt]) == 0)
            {
                solved = false;
            }
            else
            {
                if (solved)
                {
                    // No thing to do
                }
                else
                {
                    solved = true;
                    las++;
                }
            }
            if (late == 2)
            {
                answer += las;
                las = 0;
                answer -= calc(change_block);
                answer += calc(change_block - 1);
                change_block = 0;
                late = -0x3f3f3f3f;
            }
            else if (late == 1)
            {
                change_block++;
                answer -= calc(change_block - 1);
                answer += calc(change_block);
            }
            else
            {
                answer += las;
                las = 0;
            }
        }
        else if (ch == 1)
        {
            late++;
            if ((p[i] ^ w[i]) == 1)
            {
                if (solved)
                {
                    solved = false;
                }
                else
                {
                    las++;
                }
            }
            else
            {
                solved = true;
                las++;
            }
            if (late == 2)
            {
                answer += las;
                las = 0;
                answer -= calc(change_block);
                answer += calc(change_block - 1);
                change_block = 0;
                late = -0x3f3f3f3f;
            }
            else if (late == 1)
            {
                change_block++;
                answer -= calc(change_block - 1);
                answer += calc(change_block);
            }
            else
            {
                answer += las;
                las = 0;
            }
        }
        else
        {
            change_block++;
            answer -= calc(change_block - 1);
            answer += calc(change_block);
            late = 0;
        }
        i = xt;
    }
    printf("%d\n", answer);
    return 0;
}